<template>
	<view class="container">
		<view class="container-box">
			<view class="title">请选择您要绑定的人员</view>
			<view class="text">为了方便没有手机的家属也可正常使用人脸门禁，业主可以为家属上传照片</view>
			<view class="select-box">
				<view class="left-box" @tap="gobindface(numlist.pigcms_id)">
					<view class="left">
						<view class="name">{{numlist.name}}</view>
						<view class="left-icon">
							<image src="../../../static/images/right.png" class="left-img"></image>
						</view>
					</view>
					<view class="text1" v-if="numlist.is_bind_face == true">已绑定</view>
					<view class="text1" v-if="numlist.is_bind_face == false">未绑定</view>
				</view>
				<view class="left-box" @tap="gobindface(item.pigcms_id)" v-for="(item,index) in listdata">
					<view class="left">
						<view class="name">{{item.name}}</view>
						<view class="left-icon">
							<image src="../../../static/images/right.png" class="left-img"></image>
						</view>
					</view>
					<view class="text1" v-if="item.is_bind_face == true">已绑定</view>
					<view class="text1" v-if="item.is_bind_face == false">未绑定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const getvisitorList = () => {
		common.post('HouseApi&a=house_face_select', {
			village_id: _this.village_id,
			pigcms_id: _this.pigcms_id,
			page: 1,
		}, data => {
			console.log('++++', data)
			_this.numlist = data.now_village_bind;
			_this.listdata = data.village_info;
			if(_this.listdata.length == 0){
				uni.redirectTo({
					url:'/pages/village/my/faceAccessControl?add_pigcms_id=' + _this.numlist.pigcms_id
				});
			}
		});
	};
	
	export default {
		data() {
			return {
				listdata: {},
				numlist:{},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
				mobile_head_color: '',
				id:0,
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.mobile_head_color = config.config.mobile_head_color
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor + ';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				
				if (!app.globalData.is_login || !_this.pigcms_id || _this.pigcms_id == 0) {
					if (common.checkIsFooterPage("/pages/village_menu/my")) {
						wx.switchTab({
							url: "/pages/village_menu/my"
						});
					} else {
						wx.redirectTo({
							url: '/pages/village_menu/my',
						})
					}
					return false;
				}
				
				getvisitorList()
			});
		},
		methods: {
			gobindface(pigcms_id){
				uni.navigateTo({
					url:'/pages/village/my/faceAccessControl?add_pigcms_id=' + pigcms_id
				})
			}
		},
		components: {
			
		}
	}
</script>

<style>
	page {
		background: rgb(245, 245, 245);
	}

	.container {
		margin: 0;
		padding: 0;
		margin-top: 15rpx;
	}
	.container-box {
		background: #FFFFFF;
		padding: 30rpx;
	}
	.name {
		font-size: 32rpx;
		font-weight: 700;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0px;
		color: #000000;
	}
	.title {
		font-size: 28rpx;
		font-weight: 700;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #333333;
	}
	.text {
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 40rpx;
		letter-spacing: 0rpx;
		color: #ababab;
	}
	.select-box {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		flex-wrap: wrap;
		
	}
	.left-box {
		width: 270rpx;
		display: flex;
		margin-top: 20rpx;
		flex-direction: column;
		justify-content: space-between;
		background: rgb(245, 245, 245);
		border-radius: 15rpx;
		padding: 30rpx 30rpx 10rpx 30rpx;
	}
	.left {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}
	.text1 {
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #666666;
	}
	.left-icon {
		width: 30rpx;
		height: 30rpx;
		line-height: 60rpx;
	}
	.left-img {
		width: 100%;
		height: 100%;
	}
</style>
